<template>
	<view>
		<view class="item" v-if="!!imgurl">
			<img :src="imgurl" alt="" @click="onClick" />
		</view>
		<view @click="onClick" class="item" v-else> 签章</view>
		
		
	</view>
</template>

<script>
	import { registerParamsEvent } from "../../common/js/util";
	export default {
		props: {
			purpose: {
				type: String,
				defult: "",
			},
			imgurl: {
				type: String,
				defult: "",
			},
			index: {
				defult: null,
			},
			disabled: {
				defult: false,
			}
		},
		
		methods: {
			onClick() {

               console.log('signatureArgsInit 0');
				registerParamsEvent((paramKey) => {
					
					//	 item
					uni.$emit(paramKey, {
						purpose: this.purpose,
						imgurl: this.imgurl,
						disabled: this.disabled,
						index: this.index
					});
					console.log('signatureArgsInit 4');
					
				}, "signatureArgsInit");



                // called by autoGraph ,after draw、save、upload
				registerParamsEvent((item) => {
				
				// Avoid mutating a prop directly 
				// since the value will be overwritten whenever the parent component re-renders. 
				// Instead, use a data or computed property based on the prop's value. 
				// Prop being mutated: "imgurl"
				  // this.imgurl = item.url;
				 
					//// trigger event defined in ParentPage
					this.$emit("signatureHandler", item);
					
				}, "signatureCallback");


				uni.navigateTo({
					url: "/pages/manualSignature/autoGraph"
				});

			}
		}
	};
</script>

<style scoped>
	.item {
		height: 46px;
		text-align: center;
		background: #fff;
		line-height: 46px;
		border: 2rpx solid #dcdddd;
		border-radius: 15rpx;
		overflow: hidden;
	}

	img {
		width: 100%;
		height: 46px;
		background: #fff;
	}
</style>
